home *** CD-ROM | disk | FTP | other *** search
- unit LibTestForm;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- DsgnIntf, LibIntf, StdCtrls, ExtCtrls, Tabs, Menus;
-
- type
- TLibExTest = class(TForm)
- TabSet1: TTabSet;
- Notebook1: TNotebook;
- GroupBox1: TGroupBox;
- Label1: TLabel;
- BaseReg: TEdit;
- GroupBox2: TGroupBox;
- Label6: TLabel;
- Label3: TLabel;
- DisplayGrid: TCheckBox;
- SnapToGrid: TCheckBox;
- ShowComponentCaptions: TCheckBox;
- GridSizeX: TEdit;
- GridSizeY: TEdit;
- GroupBox5: TGroupBox;
- ComboBox1: TComboBox;
- Image2: TImage;
- cbLockState: TCheckBox;
- Label5: TLabel;
- PathAndBaseName: TLabel;
- Label7: TLabel;
- AppHandle: TLabel;
- Label8: TLabel;
- IDETime: TLabel;
- Label9: TLabel;
- WinSize: TLabel;
- Label4: TLabel;
- Image1: TImage;
- GroupBox4: TGroupBox;
- Label2: TLabel;
- HelpClassName: TEdit;
- ClassHelpOK: TButton;
- GroupBox3: TGroupBox;
- ComboBox2: TComboBox;
- Label10: TLabel;
- Button1: TButton;
- GroupBox6: TGroupBox;
- SelectionType: TLabel;
- SelectionName: TLabel;
- FirstSelectionType: TLabel;
- SelectedList: TListBox;
- SetLockState: TCheckBox;
- SelectAll: TButton;
- DeleteAll: TButton;
- PropertyList: TListBox;
- EventList: TListBox;
- Label11: TLabel;
- Label12: TLabel;
- Button2: TButton;
- procedure FormCreate(Sender: TObject);
- procedure HelpClassNameChange(Sender: TObject);
- procedure ClassHelpOKClick(Sender: TObject);
- procedure FormPaint(Sender: TObject);
- procedure TabSet1Change(Sender: TObject; NewTab: Integer;
- var AllowChange: Boolean);
- procedure ComboBox1Change(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure SetLockStateClick(Sender: TObject);
- procedure SelectAllClick(Sender: TObject);
- procedure DeleteAllClick(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- procedure GetPropertiesProc (Prop: TIProperty);
- procedure GetEventsProc (Prop: TIProperty);
- public
- { Public declarations }
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TLibExTest.FormCreate(Sender: TObject);
- begin
- TabSet1.Tabs := NoteBook1.Pages;
- ComboBox1.ItemIndex := 0;
- ComboBox2.ItemIndex := 0;
- ComboBox1Change (Self);
- end;
-
- procedure TLibExTest.HelpClassNameChange(Sender: TObject);
- begin
- ClassHelpOK.Enabled := HelpClassName.Text <> '';
- end;
-
- procedure TLibExTest.ClassHelpOKClick(Sender: TObject);
- begin
- DelphiIDE.ShowClassHelp (HelpClassName.Text);
- end;
-
- procedure TLibExTest.FormPaint(Sender: TObject);
- var
- Item: TIPaletteItem;
- begin
- with DelphiIDE do
- if GetToolSelected then begin
- Label4.Visible := True;
- Image1.Visible := True;
- Item := GetCurCompClass;
- try
- Item.Paint (Image1.Canvas, 0, 0);
- finally
- Item.Free;
- end;
- end
- else begin
- Label4.Visible := False;
- Image1.Visible := False;
- end;
- end;
-
- procedure TLibExTest.TabSet1Change (Sender: TObject; NewTab: Integer;
- var AllowChange: Boolean);
- var
- r: TRect;
- Idx: Integer;
- Opts: TDesignerOptions;
- Selection: TComponentList;
- begin
- NoteBook1.PageIndex := NewTab;
- { Case out on the active page name }
- if NoteBook1.Pages [NewTab] = 'Miscellaneous' then with DelphiIDE do begin
- BaseReg.Text := GetBaseRegKey;
- cbLockState.Checked := LockState;
- PathAndBaseName.Caption := GetPathAndBaseExeName;
- AppHandle.Caption := '$' + IntToHex (GetAppHandle, 8);
- IDETime.Caption := '$' + IntToHex (GetCurTime, 8);
- r := GetMainWindowSize;
- WinSize.Caption := Format ('(%d,%d)-(%d,%d)', [r.Left, r.Top, r.Right, r.Bottom]);
- end;
-
- if NoteBook1.Pages [NewTab] = 'Selections' then with CompLib do begin
- if GetSelectionName <> '' then
- SelectionName.Caption := 'Name of selected component - ' + GetSelectionName
- else SelectionName.Caption := '--No component selected--';
-
- if GetSelectionType <> '' then
- SelectionType.Caption := 'Type of selected component - ' + GetSelectionType
- else SelectionType.Caption := '--No component selected--';
-
- if GetFirstSelectionType <> '' then
- FirstSelectionType.Caption := 'Type of first selected - ' + GetFirstSelectionType
- else FirstSelectionType.Caption := '--No component selected--';
-
- Selection := TComponentList.Create;
- try
- { Delphi 3 Bug - only call GetSelection if there is a selection }
- if GetFirstSelectionType <> '' then GetSelection (Selection);
-
- SelectedList.Clear;
- if Selection.Count = 0 then SelectedList.Items.Add ('---no selection---') else
- for Idx := 0 to Selection.Count - 1 do
- with Selection [Idx] as TControl do
- SelectedList.Items.Add (Format ('%s (%s)', [Name, ClassName]));
-
- finally
- Selection.Free;
- end;
-
- Self.SetLockState.Checked := DelphiIDE.LockState;
- end;
-
- if NoteBook1.Pages [NewTab] = 'More Selection Info' then with CompLib do begin
- PropertyList.Clear;
- EventList.Clear;
- GetProperties (pkProperties, GetPropertiesProc);
- GetProperties (pkEvents, GetEventsProc);
- end;
-
- if NoteBook1.Pages [NewTab] = 'Form Designer' then with DelphiIDE do begin
- GetDesignerOptions (Opts);
- DisplayGrid.Checked := Opts.DisplayGrid;
- SnapToGrid.Checked := Opts.SnapToGrid;
- ShowComponentCaptions.Checked := Opts.ShowComponentCaptions;
- GridSizeX.Text := IntToStr (Opts.GridSizeX);
- GridSizeY.Text := IntToStr (Opts.GridSizeY);
- end;
- end;
-
- procedure TLibExTest.ComboBox1Change(Sender: TObject);
- var
- Item: TIPaletteItem;
- Cls: TComponentClass;
- begin
- with DelphiIDE do begin
- case ComboBox1.ItemIndex of
- 0: Cls := TMainMenu;
- 1: Cls := TPopupMenu;
- 2: Cls := TLabel;
- 3: Cls := TEdit;
- 4: Cls := TMemo;
- 5: Cls := TButton;
- 6: Cls := TCheckBox;
- 7: Cls := TRadioButton;
- 8: Cls := TListBox;
- 9: Cls := TComboBox;
- 10: Cls := TScrollBar;
- 11: Cls := TGroupBox;
- 12: Cls := TRadioGroup;
- 13: Cls := TPanel;
- else Cls := Nil;
- end;
-
- if Cls = Nil then Image2.Visible := False else begin
- Item := GetPaletteItem (Cls);
- try
- Item.Paint (Image2.Canvas, 0, 0);
- finally
- Item.Free;
- end;
- Image2.Visible := True;
- Image2.Invalidate;
- end;
- end;
- end;
-
- procedure TLibExTest.Button1Click (Sender: TObject);
- begin
- { This will do nothing if there's no active form }
- DelphiIDE.ExecDesignDialog (TDesignDialog (ComboBox2.ItemIndex));
- end;
-
- { @@@@ }
-
- procedure TLibExTest.GetPropertiesProc (Prop: TIProperty);
- begin
- PropertyList.Items.Add (Prop.GetName);
- Prop.Free;
- end;
-
- procedure TLibExTest.GetEventsProc (Prop: TIProperty);
- begin
- EventList.Items.Add (Prop.GetName);
- Prop.Free;
- end;
-
- procedure TLibExTest.SetLockStateClick (Sender: TObject);
- begin
- CompLib.SetLockState (SetLockState.Checked);
- end;
-
- procedure TLibExTest.SelectAllClick (Sender: TObject);
- begin
- CompLib.EditAction (eaSelectAll);
- end;
-
- procedure TLibExTest.DeleteAllClick(Sender: TObject);
- begin
- CompLib.EditAction (eaSelectAll);
- CompLib.EditAction (eaCut);
- end;
-
- procedure TLibExTest.Button2Click(Sender: TObject);
- var
- Form: TIForm;
- module: TIModule;
- begin
- Form := CompLib.GetActiveForm;
- if Form <> Nil then begin
- module := Form.GetModule;
- if module <> Nil then Module.SwapSourceFormView;
- end;
- end;
-
- end.
-
-
-
-
-
-
-